﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace OrderWeb.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        private readonly Order.OrderService service;
        public ValuesController(Order.OrderService service)
        {
            this.service = service;
        }
        // GET: api/<ValuesController>
        [HttpGet("order/{orderID}")]
        public List<Order.Order> Get(string orderID)
        {
            return service.InquiryOrders(orderID, Order.OrderService.InquiryType.OrderID);
        }

        // GET api/<ValuesController>/5
        // POST api/<ValuesController>
        [HttpPost]
        public void Post([FromBody] Order.Order order)
        {
            service.AddOrder(order);
        }

        // PUT api/<ValuesController>/5
        [HttpPut("{orderID}")]
        public void Put(string orderID, [FromBody] Order.Order order)
        {
            service.ModifyOrder(orderID, order);
        }

        // DELETE api/<ValuesController>/5
        [HttpDelete("{orderID}")]
        public void Delete(string id)
        {
            service.DeleteOrder(id);
        }
    }
}
